package com.yunxitest.yunxitest.item.typec

import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import com.yunxitest.yunxitest.Interface.IDetectItem
import com.yunxitest.yunxitest.Interface.IResultCallback

class TypecDetectManager(val context: Context, callback: IResultCallback) : IDetectItem {
    private val mBatteryBroadcastReceiver = BatteryBroadcastReceiver(callback)
    override fun startDetect() {
        registerBatteryReceiver()
    }


    override fun finish() {
        context.unregisterReceiver(mBatteryBroadcastReceiver)
    }


    /**
     * 注册电量监听的广播
     */
    private fun registerBatteryReceiver() {
        val intentFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
        context.registerReceiver(mBatteryBroadcastReceiver, intentFilter)
    }
}